//
//  GFRmTableViewCell.m
//  Qyer
//
//  Created by dlios on 15/10/19.
//  Copyright (c) 2015年 GF. All rights reserved.
//

#import "GFRmTableViewCell.h"

@implementation GFRmTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        _photoImage = [[UIImageView alloc] initWithFrame:CGRectMake(10 * WIDTH, 5 * HEIGHT, 90 * WIDTH, 80 * HEIGHT)];
        [self.contentView addSubview:_photoImage];
        
        _titleLable = [[UILabel alloc] initWithFrame:CGRectMake(105 * WIDTH, 5 * HEIGHT, 255 * WIDTH, 40 * HEIGHT)];
        [_titleLable setFont:[UIFont boldSystemFontOfSize:WIDTH * 14.]];
        [_titleLable setTextColor:[NightMode shareNightModeHandle].grayWordColor];
        [_titleLable setBackgroundColor:[UIColor clearColor]];
        [_titleLable setNumberOfLines:2];
        [self.contentView addSubview:_titleLable];
        
        _userNameLable = [[UILabel alloc] initWithFrame:CGRectMake(105 * WIDTH, 50 * HEIGHT, 255 * WIDTH, 20 * HEIGHT)];
        [_userNameLable setFont:[UIFont systemFontOfSize:WIDTH * 12.]];
        [_userNameLable setTextColor:[NightMode shareNightModeHandle].grayWordColor];
        [_userNameLable setBackgroundColor:[UIColor clearColor]];
        [self.contentView addSubview:_userNameLable];
        
        _viewsImage = [[UIImageView alloc] initWithFrame:CGRectMake(105 * WIDTH, 70 * HEIGHT, 15 *WIDTH, 15 * HEIGHT)];
        [self.contentView addSubview:_viewsImage];
        
        _viewsLable = [[UILabel alloc] initWithFrame:CGRectZero];
        [_viewsLable setFont:[UIFont systemFontOfSize:WIDTH *12.]];
        [_viewsLable setTextColor:[NightMode shareNightModeHandle].grayWordColor];
        [_viewsLable setBackgroundColor:[UIColor clearColor]];
        [self.contentView addSubview:_viewsLable];
        
        _replysImage = [[UIImageView alloc] initWithFrame:CGRectZero];
        [self.contentView addSubview:_replysImage];
        
        _replysLable = [[UILabel alloc] initWithFrame:CGRectZero];
        [_replysLable setFont:[UIFont systemFontOfSize:WIDTH * 12.]];
        [_replysLable setTextColor:[NightMode shareNightModeHandle].grayWordColor];
        [_replysLable setBackgroundColor:[UIColor clearColor]];
        [self.contentView addSubview:_replysLable];
        
        _preView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 1 * WIDTH, 90 * HEIGHT)];
        [_preView setBackgroundColor:[UIColor lightGrayColor]];
        [self.contentView addSubview:_preView];
        
        _hasView = [[UIView alloc] initWithFrame:CGRectMake(364 * WIDTH, 0, 1 * WIDTH, 90 * HEIGHT)];
        [_hasView setBackgroundColor:[UIColor lightGrayColor]];
        [self.contentView addSubview:_hasView];
    }
    return self;
}

- (void)getRmModel:(RecommendModel *)model{
    [_photoImage sd_setImageWithURL:[NSURL URLWithString:model.photo] placeholderImage:[UIImage imageNamed:@"zw.png"]];
    [_titleLable setText:model.title];
    [_userNameLable setText:model.username];
    [_viewsImage setImage:[UIImage imageNamed:@"yj.png"]];
    NSString *string = [NSString stringWithFormat:@"%ld", model.views];
 CGFloat width = [StringWithWidth widthWithText:string height:15. * HEIGHT font:[UIFont systemFontOfSize:12. * WIDTH]];
    [_viewsLable setFrame:CGRectMake(125 * WIDTH, 70 * HEIGHT, width, 15 * HEIGHT)];
    [_viewsLable setText:string];
    [_replysImage setFrame:CGRectMake(130 * WIDTH + width, 70 * HEIGHT,15 * WIDTH, 15 * HEIGHT)];
    [_replysImage setImage:[UIImage imageNamed:@"lt.png"]];
    CGFloat reWidth = [StringWithWidth widthWithText:model.replys height:15 *HEIGHT font:[UIFont systemFontOfSize:width * 12.]];
    [_replysLable setFrame:CGRectMake(150 * WIDTH + width, 70 * HEIGHT, reWidth, 15 * HEIGHT)];
    [_replysLable setText:model.replys];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
